<?php

namespace Addons\MultiLanguage;
use Admin\Controller\Addones;
use Common\Controller\Addon;

class MultiLanguageAddon extends Addon
{
    public $info = array(
        'name' => 'MultiLanguage',
        'title' => '多语言切换',
        'description' => '可切换多种显示语言',
        'status' => 1,
        'author' => '想天科技zy',
        'version' => '0.1.0',
        'has_adminlist'=>'1',
    );
    public $admin_list = array(
        '' => '',
    );

    public function install()
    {


        return true;
    }

    public function uninstall()
    {

        return true;
    }


//实现钩子
    public function multiLanguage()
    {

        $conf = $this->getAddonsConfig();

        $this->assign('conf',$conf);

        $this->display('language');
    }


    private function getAddonsConfig()
    {

        $config = S('LANGUAGE_ADDON_CONFIG');
        if (!$config) {
            $config = M('Addons')->where(array('name' => 'MultiLanguage'))->find();
            $config = json_decode($config['config'], true);
            $config = $config['choice'];
            S('LANGUAGE_ADDON_CONFIG', $config, 400);
        }
        return $config;
    }

}